<?php include '../public/header.php' ?>
<?php include '../public/header_index.php' ?>
<body class="laytp-container">
<div id="opt_nav">
</div>

<div class="layui-card" id="search-form">
    <div class="layui-card-body">
        <form class="layui-form" id="TableSearchFormId" lay-filter="TableSearchForm" onkeydown="keyTableSearch('TableSearchForm', 'datalist')">
            <div class="layui-form-item">
                <div class="layui-row">
                    <div class="layui-col-md3">
                        <label class="layui-form-label">项目名称</label>
                        <div class="layui-input-block">
                            <div id="enginidxx" class="xmselect_div">
                                <div class="xmselect_title">请选择</div>
                            </div>
                        </div>
                    </div>

                    <div class="layui-col-md3">
                        <label class="layui-form-label">编码</label>
                        <div class="layui-input-block">
                            <input type="text" name="code" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3">
                        <label class="layui-form-label">分部名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="buname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">分项名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="xiangname" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>
                    <div class="layui-col-md3 search_hide none">
                        <label class="layui-form-label">负责人</label>
                        <div class="layui-input-block">
                            <input type="text" name="baner" placeholder="请输入" class="layui-input" autocomplete="off">
                        </div>
                    </div>

                    <div class="layui-col-md3">
                        <div class="layui-form-item search-div">
                            <div class="layui-form-item layui-inline">
                                <input type="hidden" id="enginid" name="enginid">
                                <button class="laytp-btn laytp-btn-md laytp-btn-primary" id="TableSearchButton" type="button"><i class="layui-icon layui-icon-search"></i>查询</button>
                                <button class="layui-btn layui-btn-primary" onclick="listTableReset()" id="TableSearchReset" type="reset" ><i class="layui-icon layui-icon-refresh"></i>重置</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>

<div class="layui-card" id="table-card">
    <div class="layui-card-body">
        <div class="layui-row">
            <?php include '../public/engin_dao.php' ?>
            <div class="layui-col-md10" id="table_list">
                <div class="layui-card-body">
                    <table id="datalist" lay-filter="datalist"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script type="text/html" id="toolbarDemo">
    <div class = "layui-btn-container">
    </div>
</script>
<script>


    var currButAuth, currTabData;
    layui.use(["laytp",'laypage','table','dropdown','form','soulTable'], function () {
        var laypage = layui.laypage, table = layui.table, dropdown = layui.dropdown, form = layui.form, soulTable = layui.soulTable;


        $('#TableSearchReset').click(function () {
            $('.xmselect_div>xm-select').find('.xm-label-block').css('display','none');
            $('.xmselect_div').append('<div class="xmselect_title">请选择</div>');
            searchTableFunc(form, table)
        });

        setSouTableExport('项目进度汇总');
        var mytable = table.render({
            elem: "#datalist",id: "datalist"
            ,url: facade.url(ask_speed_jinhui_list),where: {}, page: true, height: 'full-140'
            ,soulSort: TabInit.soulSort,method: TabInit.method, toolbar: TabInit.toolbar, overflow: TabInit.overflow
            ,defaultToolbar: TabInit.defaultToolbar,filter: TabInit.filter
            ,request: TabInit.request,response: TabInit.response,contextmenu:get_table_contextmenu(soulTable)
            ,text: TabInit.text,totalRow: true
            ,parseData: function (res) {
                currButAuth = res.data.butauth;
                tableButShow(currButAuth);


                xmselect_dan('enginidxx', res.data.enginidArr, res.data.is_enginid, function (res) {
                    setTimeout(function () {
                        searchTableFunc(form, table);
                    },100)
                })


                render_from();
                return {
                    "code": res.code,
                    "msg": res.message,
                    "count": res.data.data.total,
                    "data": res.data.data.data
                };
            }
            , cols: [[
                {type: "checkbox", fixed: 'left'}
                ,{type:'numbers',title:'序号',totalRowText: '合计',fixed:'left'}
                ,{field:'enginname',title:'项目名称',templet: function(d){
                        return '<span class="colorlan" onclick="openPage(\'../engin/show.php?id='+d.enginid+'\')">'+d.enginname+'</span>';
                    }}
                ,{field: 'code', title: '编码'}
                ,{field: 'buname', title: '分部名称'}
                ,{field: 'xiangname', title: '分项名称'}
                ,{field: 'unit', title: '单位'}
                ,{field: 'price', title: '单价(元)'}
                ,{field: 'num', title: '总计划工程量 A'}
                ,{field: 'chanfee', title: '总计划产值(元) B'}
                ,{field: 'duration', title: '总计划工期(天) C'}
                ,{field: 'startdt', title: '计划开工日期'}
                ,{field: 'baner', title: '负责人'}
                ,{field: 'shifindt', title: '实际开工日期'}
                ,{field: 'leishinum', title: '开累完成工程量 D'}
                ,{field: 'leishichan', title: '开累完成产值(元) E',totalRow: true}
                ,{field: 'leishiday', title: '开累施工天数(天) F'}
                ,{field:'dangjin',title:'当前进度 G(D/A)',templet: function(d){
                        return d.dangjin+'%';
                    }}
                ,{field:'gongbi',title:'工期占比 H(F/C)',templet: function(d){
                        return d.gongbi+'%';
                    }}
                ,{field:'gongjing',title:'工期完成量预警',templet: function(d){
                        if(d.gongjing){
                            return '正常';
                        }else{
                            return '<span class="colorhong">滞后</span>';
                        }
                    }}
                ,{field: 'dainum', title: '待完成量( A-D)'}
                ,{field: 'daichan', title: '待完成产值(元) (B-E)',totalRow: true}
                ,{field: 'sheng', title: '剩余工期(天) (C-F)'}
                ,{field: 'zuijin', title: '最近填报月份'}
            ]]
            , done: function (res) {
                soulTable.render(this);
                currTabData = res.data;
                $.each(currTabData, function(index,item){
                    var chk = $('tr[data-index=' + item.LAY_TABLE_INDEX + '] .tab-list-authbut');
                    for (var key in currButAuth) {
                        if(currButAuth[key].pagetype === 0 || currButAuth[key].pagetype === 1){
                            chk.append(' <a ' +
                                'href="javascript:;" ' +
                                'class="bar_opt layui-hide" ' +
                                'lay-event="search" ' +
                                'data-butname="'+currButAuth[key].butname+'" ' +
                                'data-title="'+currButAuth[key].title+'" ' +
                                'onclick="auth_but_func_'+currButAuth[key].butname+'(\''+currButAuth[key].title+'\', '+index+')"' +
                                '>'+currButAuth[key].title+'' +
                                '</a>');
                        }
                    }
                });
                show_tab_but(currTabData);
            }
        });


        listTableSearch(form, table);
    });





</script>
</body>
</html>
